<?php

namespace Sbm\ControlPanel;

use Sbm;

$order = empty($_GET['order']) ? '' : $_GET['order'];


switch ($order)
{
	case 'number-desc':
		$order_by = '`id` DESC';
		break;
	case 'number-asc':
		$order_by = '`id` ASC';
		break;
	case 'title':
	default:
		$order_by = '`name` ASC';
		break;
}

$data = array();

$s = "SELECT 
	        * 
	  FROM 
	        `{master}`
	  ORDER BY 
	        " . $order_by;
$q = $db->Query($s);
while ($r = $q->FetchRow())
{
	$item = new Sbm\Master($r);
	$data[] = $item;
}
?>